package com.winsomely.leecode;

/**
 * 验证回文串
 * 
 * @author liujiawei
 *
 */
public class IsPalindrome {

	/**
	 * [0 - 9] [48 - 57] [A - Z] [65 - 90] [a - z] [97 - 122]
	 * 
	 * 
	 * @param s
	 * @return
	 */
	public boolean isPalindrome(String s) {
		int b = 0, e = s.length() - 1;
		while (b <= e) {
			char bc = s.charAt(b);
			char ec = s.charAt(e);

			if (!Character.isLetterOrDigit(bc)) {
				b++;
				continue;
			}
			if (!Character.isLetterOrDigit(ec)) {
				e--;
				continue;
			}
			if (Character.toLowerCase(bc) != Character.toLowerCase(ec)) {
				return false;
			}
			b++;
			e--;
		}
		return true;
	}

	public static void main(String[] args) {
		IsPalindrome t = new IsPalindrome();
		System.out.println(t.isPalindrome("Sore was I ere I saw Eros."));
	}

}
